package com.gurid.service.edu.controller.api;

import com.gurid.common.base.result.R;
import com.gurid.service.edu.entity.Course;
import com.gurid.service.edu.entity.Teacher;
import com.gurid.service.edu.service.CourseService;
import com.gurid.service.edu.service.TeacherService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "ApiIndexController", description = "首页展示")
@CrossOrigin
@RestController
@RequestMapping("/api/edu/index")
@Slf4j
public class ApiIndexController {

    @Autowired
    private CourseService courseService;
    @Autowired
    private TeacherService teacherService;

    @Operation(description = "课程和讲师的首页数据")
    @GetMapping
    public R index() {
        //查询热门课程
        List<Course> courseList = courseService.selectHotCourses();
        //查询推荐讲师
        List<Teacher> teacherList = teacherService.selectHotTeachers();

        return R.ok().data("courseList", courseList).data("teacherList", teacherList);
    }
}
